package com.ruoyi.wms.strategy;

import com.ruoyi.wms.mapper.MovementOrderMapper;
import com.ruoyi.wms.util.TimeRangeUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
@Component
@RequiredArgsConstructor
public class MovementOrderTrendStrategy extends BaseOrderTrendStrategy{
    private final MovementOrderMapper movementOrderMapper;
    @Override
    public List<Map<LocalDateTime, Integer>> queryTrend(LocalDateTime date, Integer granularity, Integer optType, Integer orderStatus) {
        // 实现移库订单趋势统计逻辑
        // 获取起始和结束时间
        List<LocalDateTime> timeRange = getTimeRange(date, granularity);
        LocalDateTime beginTime = timeRange.get(0);
        LocalDateTime endTime = timeRange.get(1);

        // 查询移库单趋势统计
        return movementOrderMapper.queryMovementOrderTrend(beginTime, endTime, granularity, orderStatus);
    }

    @Override
    public boolean supports(Integer orderType) {
        // 判断是否支持移库订单类型
        return Integer.valueOf(2).equals(orderType);// 2表示移库订单类型
    }
}
